package logic

import (
	"bw-renting/common"
	"context"
	"encoding/json"

	"bw-renting/user-rpc/internal/svc"
	"bw-renting/user-rpc/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type RealLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRealLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RealLogic {
	return &RealLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// Todo:用户实名认证
func (l *RealLogic) Real(in *user.RealNameReq) (*user.RealNameRes, error) {
	// todo: add your logic here and delete this line
	r := common.Auth(in.Name, in.Code)
	if r == "不一致" {
		return &user.RealNameRes{
			Status: "0",
		}, nil
	}
	f, _ := json.Marshal(r)
	return &user.RealNameRes{
		Status: string(f),
	}, nil
}
